package jch.learn.java.advanced.chapter2_InputAndOutput.objectStream;

import java.io.ObjectStreamException;
import java.io.Serializable;

public class OrientationSingle implements Serializable {

    private int value;

    private OrientationSingle(int value){
        this.value = value;
    }

    public static final OrientationSingle VALUE_1 = new OrientationSingle(1);
    public static final OrientationSingle VALUE_2 = new OrientationSingle(2);

    protected Object readResolve() throws ObjectStreamException {
        if (value == 1) return VALUE_1;
        if (value == 2) return VALUE_2;
        throw new ObjectStreamException("NOT FOUNT"){
        };
    }

}
